{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#练习使用requests库访问下面网站并保存网页原始内容（提示：善用dir, help）：\n",
    "#https://detail.zol.com.cn/cpu_advSearch/subcate28_1.html\n",
    "#https://www.2345.com/\n",
    "#https://music.163.com/\n",
    "import requests\n",
    "r = requests.get('https://detail.zol.com.cn/cpu_advSearch/subcate28_1.html')\n",
    "c = r.content\n",
    "with open('adv.html','wb') as f:\n",
    "    f.write(c)\n",
    "h = requests.get('https://www.2345.com/')\n",
    "cf = h.content\n",
    "with open('2345.html','wb') as fy:\n",
    "    fy.write(cf)\n",
    "g = requests.get('https://music.163.com/')\n",
    "k = g.content\n",
    "with open('music.html','wb') as fh:\n",
    "    fh.write(k)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#使用requests库爬取汽车之家（https://car.autohome.com.cn）网站上的所有品牌汽车的名称和所有品牌下面的子型号名称，并存入csv文件\n",
    "import requests\n",
    "r = requests.get('https://car.autohome.com.cn')\n",
    "c = r.content\n",
    "with open('cars.csv','wb') as f:\n",
    "    f.write(c)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "1baa965d5efe3ac65b79dfc60c0d706280b1da80fedb7760faf2759126c4f253"
  },
  "kernelspec": {
   "display_name": "Python 3.8.10 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
